import request from "@/utils/request";
const organizationalAPI = {
  //获取部门列表
  getDepartmentList(queryParams: depPageQuery) {
    let query = encodeURIComponent(JSON.stringify({ ...queryParams }));
    return request<any, PageResult<Department[]>>({
      url: `/core/api/dingtalk/department/list?object=${query}`,
      method: "get",
    });
  },
  departmentsync() {
    return request({
      url: `/core/api/dingtalk/department/sync`,
      method: "post",
      // data: data,
    });
  },
  //获取员工列表
  getEmployeeList(queryParams: emPageQuery) {
    let query = encodeURIComponent(JSON.stringify({ ...queryParams }));
    return request<any, PageResult<Employee[]>>({
      url: `/core/api/dingtalk/department/employee/list?object=${query}`,
      method: "get",
    });
  },

  // getDepartmentList(deptId: string) {
  //   return request<any, any>({
  //     url: `/core/api/dingtalk/department/list`,
  //     method: "get",
  //     params: { deptId: deptId },
  //   });
  // },
  //部门详情
  getDepartmentDetail(deptId: number) {
    return request<any, any>({
      url: `/core/api/dingtalk/department/detail`,
      method: "get",
      params: { deptId: deptId },
    });
  },
  //用户列表
  getUserList(deptId: number) {
    return request<any, any>({
      url: `/core/api/dingtalk/user/list`,
      method: "get",
      params: { deptId: deptId },
    });
  },
  getUSerDetail(userId: number) {
    return request<any, any>({
      url: `/core/api/dingtalk/user/detail`,
      method: "get",
      params: { userId: userId },
    });
  },
};
export default organizationalAPI;
// /** 登录用户信息 */
// export interface UserInfo {
//   /** 用户ID */
//   userId?: number;

//   /** 用户名 */
//   username?: string;

//   /** 昵称 */
//   nickname?: string;

//   /** 头像URL */
//   avatar?: string;

//   /** 角色 */
//   roles: string[];

//   /** 权限 */
//   perms: string[];
// }

// /**
//  * 用户分页查询对象
//  */
export interface depPageQuery extends PageQuery {
  /** 工序名称 */
  // name?: string;

  /** 创建时间 */
  timeScopes?: string;
}
export interface emPageQuery extends PageQuery {
  deptName?: string;
  employeeId?: string;
  employeeName?: string;
  /** 工序名称 */
  // name?: string;

  /** 创建时间 */
  // timeScopes?: string;
}

/**
 * 部门响应数据
 */
export interface Department {
  autoAddUser: boolean;
  children: null;
  companyName: string;
  createDeptGroup: boolean;
  createTime: string;
  deptId: string;
  deptManagerUseridList: null;
  hideDept: boolean;
  name: string;
  orderNum: number;
  outerDept: boolean;
  outerPermitDepts: null;
  outerPermitUsers: null;
  parentId: number;
  sourceIdentifier: null;
  updateTime: null;
  userPermitDepts: null;
  employees: Employee[];
}

/**
 * 员工响应数据
 */
export interface Employee {
  admin: boolean;
  boss: boolean;
  createName: string;
  createTime: string;
  createUser: number;
  deptId: string;
  dingStatus: boolean;
  dingUserId: string;
  email: null;
  employeeId: string;
  employeeName: string;
  entryDate: null;
  id: number;
  isDelete: number;
  leader: boolean;
  leaveDate: null;
  mobile: null;
  modifyName: string;
  modifyTime: string;
  modifyUser: number;
  phone: null;
  position: string;
  status: number;
  workPlace: null;
}
